﻿HmJS.$Import('core.fx');

/*
---
version: 0.1-0
description: Extends the Element Class to fade it's content in character by character
license: MIT-style
download: http://mootools.net/forge/p/element_string_fade
source: http://github.com/CBeloch/Element.String.Fade

authors:
- Christopher Beloch

requires: 
core/1.2.4: '*'

provides: [Element.fadeString]
 
...
*/

HmJS.register('base.element.fadestring', function ($ns) {

	Element.implement({
		fadeString: function (duration) {
			slogan = this.get('html');
			this.set('html', '');
			el = this;
			Object.each(slogan, function (item, i) {
				var n = new Element('span', {
					'html': item,
					'styles': {
						'opacity': 0
					}
				});
				n.inject(el);

				m = new Fx.Tween(n, {
					'duration': 'long',
					'property': 'opacity'
				});
				m.start.pass([1], m).delay((duration ? duration : 75) * (1 + i.toInt()));
			});

			return this;
		}
	});

});
